package com.example.imagechange;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends Activity {
	
	ImageView imgView;
	Bitmap previousImage;
	Bitmap afterImage;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		imgView = (ImageView)findViewById(R.id.afterImage);
		previousImage = BitmapFactory.decodeResource(getResources(), R.drawable.image);
		
		View.OnClickListener mClickListener = new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if(v.getId() == R.id.button1){
					Matrix sideInversion = new Matrix();
					sideInversion.setScale(-1,-1);
					afterImage = Bitmap.createBitmap(previousImage,0,0,previousImage.getWidth(),previousImage.getHeight(),sideInversion,false);
					imgView.setImageBitmap(afterImage);
				}else if(v.getId() == R.id.button2){
					
				}
			}
		};
		
		findViewById(R.id.button1).setOnClickListener(mClickListener);
		findViewById(R.id.button2).setOnClickListener(mClickListener);
		findViewById(R.id.button3).setOnClickListener(mClickListener);
		findViewById(R.id.button4).setOnClickListener(mClickListener);
		findViewById(R.id.button5).setOnClickListener(mClickListener);	
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
